let express = require("express");
let router = express.Router();
const Query = require("../utils/db.js");
// 登录路由
router.get("/", (req, res) => {
  res.render("login");
});
// 点击登录路由
router.post("/", async (req, res) => {
  let { username, password } = req.body;
  let sql = ` SELECT * FROM users WHERE username = '${username}' AND password = '${password}' `;
  let resObj = await Query(sql);
  if (resObj.result.length > 0) {
    res.send("登录成功");
  } else {
    res.send("用户名或密码错误");
  }
});
module.exports = router;
